<!--
    说明：招聘企业-职位详情
 -->
<template>
  <section class="pc-review-page">
    <!-- 不同类型的职位，操作按钮逻辑不一样，在父组件通过插槽处理 -->
    <slot v-if="showBtn" name="btnBox" />
    <!-- 公司基本信息 -->
    <div class="job-info">
      <div class="row1">
        <div class="left">
          <div class="row1-1">
            <span class="title">{{ jobInfo.jobName }}</span>
            <span
              class="strong"
            >{{ jobInfo.lowestSalary || 0 }}-{{
              jobInfo.highestSalary || 0
            }}元/天</span>
            <span
              class="normal"
            >招聘人数：{{ jobInfo.recruitmentCount || 0 }}</span>
            <span
              class="normal"
            >工作语言：{{ jobInfo.jobLanguage || "中文" }}</span>
          </div>

          <div class="row2">
            <span v-if="jobInfo.city">{{ jobInfo.city }}</span>
            <span
              v-if="jobInfo.practicePeriod || jobInfo.workPeriod"
              class="line"
            />
            <span
              v-if="jobInfo.practicePeriod"
            >{{ jobInfo.practicePeriod }}个月</span>
            <span v-if="jobInfo.workPeriod" class="line" />
            <span v-if="jobInfo.workPeriod">{{ jobInfo.workPeriod }}</span>
            <span v-if="jobInfo.education" class="line" />
            <span v-if="jobInfo.education">{{ jobInfo.education }}</span>
            <span v-if="jobInfo.identify" class="line" />
            <span v-if="jobInfo.identify">{{
              ["在校", "应届"][jobInfo.identify]
            }}</span>
          </div>
          <div class="row3">
            <div
              v-for="(item, index) in jobInfo.welfareTags"
              :key="index"
              class="tag"
            >
              {{ item }}
            </div>
          </div>
        </div>
        <div class="right-hire">
          <div class="row1">发布时间：{{ moment(jobInfo.publishTime).format('yyyy-MM-DD') }}</div>
          <div class="row2">点击量：{{ jobInfo.clickCount }}</div>
        </div>
      </div>
      <div class="row4">
        <img
          v-imgError
          class="logo-img"
          :src="companyInfo.companyLogo"
          alt="logo-img"
        >
        <div class="right-block" @click="linkTo('company', jobInfo.companyId)">
          <div class="name">{{ companyInfo.companyName }}</div>
          <div class="area">{{ companyInfo.industry }}</div>
        </div>
      </div>
    </div>
    <section class="company-info">
      <!-- 职位描述 -->
      <div class="row-item">
        <div class="title">职位描述</div>
        <div class="company-desc">
          {{ jobInfo.jobDescription || "--" }}
        </div>
      </div>
      <!-- 企业简介 -->
      <div class="row-item">
        <div class="title">{{ jobInfo.companyName }}简介</div>
        <div class="company-desc">{{ companyInfo.introduction || "--" }}</div>
        <div class="safe-tips">
          <div class="title">安全提示</div>
          <div class="text">
            数据学徒实习平台严禁用人单位作出任何损害求职者合法权益的违法违规行为，包括单不限于扣押求职者证件，收取求助者财物，向求职者集资，让求职者入股，诱导求职者异地入职，异地参与培训等，您一旦发现此类欣慰，请立即举报
          </div>
          <img class="safe-icon" src="@/assets/images/safe.png" alt="">
        </div>
      </div>
      <!-- 企业地址 -->
      <div class="row-item">
        <div class="title">企业地址</div>
        <div class="company-address">
          <div class="item">
            <span class="position-icon" />
            {{ jobInfo.workAddress }}
          </div>
        </div>
      </div>
    </section>
  </section>
</template>
<script>
import { getEducationName, getWorkPeriodName } from '@/utils/frontDataDict'
import { formatJobTime } from '@/utils'
import { getCompanyDetail } from '@/api/school-admin-api/hireManage/index.js'
import { deepClone } from '../../../../utils'
import moment from 'moment'
export default {
  name: 'JobDetail',
  data() {
    return {
      moment: moment,
      jobInfo: {},
      companyInfo: {},
      showBtn: true
    }
  },
  mounted() {},
  methods: {
    open(jobInfo, isShowBtn) {
      this.showBtn = isShowBtn
      this.jobInfo = deepClone(jobInfo)
      if (this.jobInfo) {
        try {
          this.jobInfo.education = getEducationName(
            this.jobInfo.education,
            true
          )
        } catch {
          () => {}
        }
        try {
          if (Array.isArray(JSON.parse(this.jobInfo.industry))) {
            this.jobInfo.industry = JSON.parse(this.jobInfo.industry)[1]
          }
        } catch {
          () => {}
        }
        try {
          const cityList = JSON.parse(this.jobInfo.city)
          if (Array.isArray(cityList)) {
            this.jobInfo.city = cityList[cityList.length - 1]
          }
        } catch {
          () => {}
        }

        try {
          if (Array.isArray(JSON.parse(this.jobInfo.welfareTags))) {
            this.jobInfo.welfareTags = JSON.parse(this.jobInfo.welfareTags)
          }
        } catch {
          () => {}
        }
        this.jobInfo.publishTime &&
          (this.jobInfo.publishTime = formatJobTime(
            new Date(this.jobInfo.publishTime / 1000)
          ))
        this.jobInfo.workPeriod &&
          (this.jobInfo.workPeriod = getWorkPeriodName(
            this.jobInfo.workPeriod
          ))
        this.jobInfo.companyId &&
          getCompanyDetail(this.jobInfo.companyId).then((vv) => {
            if (vv.data) {
              try {
                if (Array.isArray(JSON.parse(vv.data.companyAddress))) {
                  vv.data.companyAddress = JSON.parse(vv.data.companyAddress)
                }
              } catch {
                () => {}
              }
              try {
                if (Array.isArray(JSON.parse(vv.data.industry))) {
                  vv.data.industry = JSON.parse(vv.data.industry)[1]
                }
              } catch {
                () => {}
              }
              this.companyInfo = vv.data
            }
          })
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.pc-review-page {
  position: relative;
  background: #fff;
  .company-info {
    position: relative;
    width: 100%;
    background: #fff;
    border-radius: 10px;
    border: 1px solid #fff;
    padding: 40px 40px 30px;
  }
  .job-info {
    position: relative;
    width: 100%;
    background: #f9f9f9;
    border-radius: 10px;
    border: 1px solid #f0f0f0;
    padding: 20px 20px 20px;
    .row1 {
      display: flex;
      flex-flow: row nowrap;
      .left {
        flex: 1;
        .row1-1 {
          margin-bottom: 15px;
          .title {
            font-size: 22px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #37383d;
            line-height: 30px;
            margin-right: 15px;
            vertical-align: bottom;
          }
          .strong {
            font-size: 20px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #9597a0;
            line-height: 30px;
            vertical-align: bottom;
            margin-right: 15px;
          }
          .normal {
            font-size: 20px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #9597a0;
            line-height: 30px;
            vertical-align: bottom;
            margin-right: 15px;
          }
        }
      }

      .right-hire {
        position: relative;
        width: 135px;
        .row1 {
          font-size: 18px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597a0;
          line-height: 24px;
          margin-bottom: 10px;
          text-align: right;
        }

        .row2 {
          font-size: 18px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597a0;
          line-height: 24px;
          text-align: right;
        }
      }
    }

    .row2 {
      font-size: 22px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #9597a0;
      line-height: 30px;
      margin-bottom: 15px;

      .line {
        display: inline-block;
        width: 1px;
        height: 14px;
        background: #9ca8be;
        margin: 0 15px;
      }
    }

    .row3 {
      position: relative;
      margin-bottom: 15px;

      .tag {
        display: inline-block;
        background: rgba(47, 142, 254, 0.07);
        border-radius: 6px;
        border: 1px solid #2f8efe;
        font-size: 18px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #2f8efe;
        line-height: 32px;
        text-align: center;
        padding: 0 10px;
        margin-right: 10px;
      }
    }

    .row4 {
      position: relative;
      overflow: hidden;

      .logo-img {
        display: block;
        width: 80px;
        height: 80px;
        float: left;
        background: #ffffff;
        border-radius: 8px;
        border: 1px solid #d4d6da;
        margin-right: 15px;
      }

      .right-block {
        position: relative;
        height: 80px;
        overflow: hidden;
        cursor: pointer;
        display: flex;
        flex-flow: column nowrap;
        justify-content: space-between;
        .name {
          font-size: 22px;
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 600;
          color: #37383d;
          line-height: 40px;
          margin-bottom: 15px;
        }

        .area {
          font-size: 20px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597a0;
          line-height: 22px;
        }
      }
    }

    .btn {
      display: block;
      padding: 0 15px;
      height: 40px;
      line-height: 40px;
      background: #3d6cb0;
      border-radius: 20px;
      font-size: 18px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #ffffff;
      text-align: center;
      cursor: pointer;

      .edit-icon {
        display: inline-block;
        width: 18px;
        height: 20px;
        margin-right: 10px;
        background: url("../../../../assets/images/edit-icon.png") no-repeat center
          center / cover;
      }

      .send-icon {
        display: inline-block;
        width: 18px;
        height: 20px;
        margin-right: 10px;
        background: url("../../../../assets/images/job/send.png") no-repeat center
          center / cover;
      }
    }

    .edit {
      position: absolute;
      right: 200px;
      bottom: 50px;
      &:hover {
        color: #2f8efe;
        box-shadow: 0px 4px 15px 0px rgba(0, 0, 0, 0.08);
      }
    }

    .send {
      position: absolute;
      right: 35px;
      bottom: 50px;
      &.disabled {
        background: #ccc;
        cursor: not-allowed;
      }
      &:hover {
        color: #2f8efe;
        box-shadow: 0px 4px 15px 0px rgba(0, 0, 0, 0.08);
      }
    }
  }

  .row-item {
    position: relative;
    width: 100%;
    padding: 32px 0 45px;
    border-bottom: 1px solid #d4d6da;

    &:last-child {
      border-bottom: 1px solid #fff;
    }

    .title {
      position: relative;
      text-align: left;
      font-size: 28px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #37383d;
      line-height: 40px;
      margin-bottom: 25px;

      .all {
        position: absolute;
        right: 0;
        bottom: 0;
        font-size: 24px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #2f8efe;
        line-height: 33px;
        vertical-align: bottom;
        cursor: pointer;

        .all-icon {
          display: inline-block;
          width: 32px;
          height: 32px;
          background: url("../../../../assets/images/check_all.png") no-repeat
            center center / cover;
          vertical-align: bottom;
          margin-right: 15px;
        }
      }
    }

    .job-item {
      position: relative;
      background: #ffffff;
      border-radius: 10px;
      border: 1px solid #d4d6da;
      padding: 25px;
      cursor: pointer;

      .job-name {
        font-size: 28px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #37383d;
        line-height: 40px;
        margin-bottom: 35px;

        .salary {
          font-size: 24px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #9597a0;
          line-height: 40px;
          float: right;
        }
      }

      .other {
        font-size: 22px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #9597a0;
        line-height: 30px;

        .line {
          position: relative;
          display: inline-block;
          width: 1px;
          height: 14px;
          background: #9597a0;
          margin: 0 18px;
        }
      }
    }

    .company-desc {
      font-size: 24px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #9597a0;
      line-height: 38px;
    }

    .company-address {
      position: relative;

      .item {
        font-size: 26px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #37383d;
        margin-top: 35px;
        line-height: 37px;
        cursor: pointer;

        &:first-child {
          margin-top: 0;
        }

        .position-icon {
          display: inline-block;
          width: 24px;
          height: 29px;
          margin-right: 15px;
          background: url("../../../../assets/images/position.png") no-repeat
            center center / cover;
          vertical-align: middle;
        }
      }
    }

    .safe-tips {
      position: relative;
      padding: 30px 269px 20px 20px;
      background: #ffffff;
      border-radius: 10px;
      border: 1px solid #d4d6da;
      margin-top: 40px;

      .title {
        font-size: 28px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #2f8efe;
        line-height: 40px;
        margin-bottom: 12px;
      }

      .text {
        font-size: 22px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #9597a0;
        line-height: 38px;
      }

      .safe-icon {
        position: absolute;
        right: 70px;
        top: 50%;
        margin-top: -66px;
        width: 112px;
        height: 112px;
      }
    }

    .contact-row {
      position: relative;
      margin-bottom: 35px;

      .left {
        display: inline-block;
        width: 168px;
        font-size: 24px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #9597a0;
        line-height: 33px;
      }

      .right {
        font-size: 24px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #37383d;
        line-height: 33px;
      }
    }
  }
}
::v-deep .el-breadcrumb__inner {
  font-size: 20px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #37383d;
  line-height: 28px;
  cursor: pointer;
}
</style>
